<template>  
  <div>  
    <h2>{{ product.name }}</h2>  
    <p>{{ product.price }}</p>  
    <button @click="addToCart(product)">添加到购物车</button>  
  </div>  
</template>  
  
<script>  
export default {  
  props: ['product'],  
  methods: {  
    addToCart(product) {  
      this.$store.commit('addToCart', product);  
    },  
  },  
};  
</script>